// 获取当前时间
function getNowDate() {
	let oDate = new Date(); /*Date对象*/
	let Y = oDate.getFullYear();
	let M = toDate(oDate.getMonth() + 1);
	let D = toDate(oDate.getDate());
	let dateList = ["日", "一", "二", "三", "四", "五", "六"];
	let W = new Date().getDay();
	let nowData =
		Y + "年" + M + "月" + D + "日" + " " + "星期" + dateList[W];
	return nowData
}

function getNowDate2() {
	let oDate = new Date(); /*Date对象*/
	let Y = oDate.getFullYear();
	let M = toDate(oDate.getMonth() + 1);
	let D = toDate(oDate.getDate());
	let nowData =
		Y + "-" + M + "-" + D;
	return nowData
}

function getNowTime() {
	let oDate = new Date(); /*Date对象*/
	let H = toDate(oDate.getHours());
	let M = toDate(oDate.getMinutes());
	let S = toDate(oDate.getSeconds());
	let t = H + ":" + M + ":" + S;
	return t
}

function getFullDate() {
	return getNowDate2() + " " + getNowTime();
}

function getPreDate(day) {
	var today = new Date();
	var targetday_milliseconds = today.getTime() - 1000 * 60 * 60 * 24 * day;
	today.setTime(targetday_milliseconds);
	var tYear = today.getFullYear();
	var tMonth = today.getMonth();
	var tDate = today.getDate();
	tMonth = tMonth + 1;
	return tYear + "-" + toDate(tMonth) + "-" + toDate(tDate);
}

function toDate(n) {
	if (n < 10) {
		return "0" + n;
	} else {
		return "" + n;
	}
}

export {
	getNowDate,
	getNowDate2,
	getNowTime,
	getFullDate,
	getPreDate
}
